package com.sxx.beautifulcity.database;

import com.sxx.beautifulcity.entity.greendao.Detail;
import com.sxx.beautifulcity.entity.greendao.DetailDao;

import java.security.PublicKey;
import java.util.List;

/**
 * Created by dllo on 15/11/9.
 */
public class DetailStoreHelpter {
    private DaoSingleton instance = DaoSingleton.getInstance();
    private DetailDao detailDao;

    public DetailStoreHelpter() {
        this.detailDao = instance.getDetailDao();
    }

    public void setInstance(DaoSingleton instance) {
        this.instance = instance;
    }

    public void saveDetailList(List<Detail> list){
        detailDao.insertInTx(list);
    }

    public void deleteDetail(){
        detailDao.deleteAll();
    }
    public List<Detail> queryByID(long id){
        List<Detail> list = detailDao.queryBuilder().where(DetailDao.Properties.DetialId.eq(id)).list();

        return list;
    }

    public List<Detail> queryDetailList(){
        return detailDao.loadAll();
    }

    public void deleteById(long id){
        detailDao.deleteByKey(id);
    }
}
